#!/usr/bin/python
# -*- coding: utf-8 -*-
# Create Time :  2007-1-16 22:22:04测试

from django.db import models

# Create your models here.

class Client(models.Model):

    client_name = models.CharField(maxlength=256, unique=True) # Client Name
    client_email = models.EmailField() # Client Email
    client_info = models.TextField(maxlength=1000) # Client Infomations
    client_ipasswd = models.CharField(maxlength=256) # Client init password
    client_reg_ip = models.CharField(maxlength=256) # client Reg IP address
    
    def __str__(self):
        return 'Client_name:[%s] Client_Ipasswd:[%s] Client_reg_ip:[%s]' % (self.client_name, \
                self.client_ipasswd, \
                self.client_reg_ip)
    
    class Admin:
        pass
    

class LicData(models.Model):
    
    client_id = models.ForeignKey(Client) 
    client_reg_stats = models.BooleanField(default=True) # Client reg stats
    client_reg_gen_date = models.DateTimeField(auto_now_add=True) # client reg code gen time
    client_reg_set_date = models.DateTimeField(auto_now=True) # client reg date time
    client_reg_code = models.CharField(maxlength=40) # client reg code
    client_reg_reset_times = models.IntegerField(default=1) # client reset reg code times
    
    def __str__(self):
        return 'Client_reg_code:[%s] Client_reg_status:[%s] Client_reset_times:[%s] Client_reg_gen_date:[%s] Client_reg_set_date[%s]' % \
                (self.client_reg_code, \
                str(self.client_reg_stats), \
                str(self.client_reg_reset_times), \
                str(self.client_reg_gen_date), \
                str(self.client_reg_set_date))
        
    def _get_regcode_reset_times(self):
        return self.client_reg_reset_times
    
    regcode_reset_times = property(_get_regcode_reset_times)
    

    class Admin:
        pass